package com.exercises;


class Exercise1221 {


    public int balancedStringSplit(String s) {
        int result = 0, curse = 0;
        for (char c : s.toCharArray()) {
            if (c == 'L') {
                curse++;
            } else {
                curse--;
            }
            if (curse == 0) result++;
        }
        return result;
    }
}

